/*
 * @lc app=leetcode.cn id=78 lang=golang
 *
 * [78] 子集
 */

// @lc code=start
func subsets(nums []int) [][]int {
	n := len(nums)

	ans := make([][]int, 0)

	cur := []int{}
	var backtrace func(index int)

	backtrace = func(index int) {
		if index == n {
			tmp := append([]int{}, cur...)
			ans = append(ans, tmp)
			return
		}
		cur = append(cur, nums[index])
		backtrace(index + 1)
		cur = cur[:len(cur)-1]
		backtrace(index + 1)
	}
	backtrace(0)

	return ans
}

// @lc code=end

